﻿using System.Linq;
using EntityFramework.Database.Management;

namespace Sample.Application
{
    public partial class MyContext : IObjectContext
    {
        public IQueryable<T> GetIQueryable<T>() where T : class
        {
            return CreateObjectSet<T>().AsQueryable();
        }

        public void Add<T>(T entity) where T : class
        {
            CreateObjectSet<T>().AddObject(entity);
        }

        public void Delete<T>(T entity) where T : class
        {
            CreateObjectSet<T>().DeleteObject(entity);
        }

        public void Attach<T>(T entity) where T : class
        {
            CreateObjectSet<T>().Attach(entity);
        }

        public void Detach<T>(T entity) where T : class
        {
            CreateObjectSet<T>().Detach(entity);
        }
    }
}